package com.qfedu.controller;

import com.alibaba.fastjson.JSONObject;
import com.qfedu.entity.ListSong;
import com.qfedu.service.ListSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author zhang
 * @Title: commonValidateAdd
 * @date : 2022/2/25 15:08
 */
@Controller
public class ListSongController {

    @Autowired
    private ListSongService listSongService;

    @RequestMapping("/listSong/detail")
    @ResponseBody
    public List<ListSong> findAllListSong(int songListId){
        return listSongService.findAllListSong(songListId);

    }

    @RequestMapping("/ListSong/delete")
    @ResponseBody
    public int deleteListSong(ListSong listSong) {

        System.out.println(listSong);
        return listSongService.deleteListSong(listSong);
    }


    @RequestMapping("/ListSong/add")
    @ResponseBody
    public JSONObject addListSong(ListSong listSong){
        int i = listSongService.addListSong(listSong);
        JSONObject jsonObject = new JSONObject();
        if (i > 0){
            jsonObject.put("code",1);
            jsonObject.put("msg","修改成功");
        }else {
            jsonObject.put("code",0);
            jsonObject.put("msg","修改失败");
        }
        return jsonObject;

    }




}
